SET(TARGET_NAME ExeUiOverall)

#PROJECT(${TARGET_NAME})
#必须要有的宏定义
#ADD_DEFINITIONS (-DLIB_OSG_EXPORT)

IF (WIN32 )
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8")
endif()

if(UNIX)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
    #set(CMAKE_CXX_STANDARD 11)
    #set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

if(APPLE)
    #set(CMAKE_CXX_STANDARD 11)
    #set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

#INCLUDE_DIRECTORIES("..\\..\\include")
#LINK_DIRECTORIES("..\\..\\lib")
IF (CMAKE_CL_64)
ELSE()
ENDIF()
	INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/${TARGET_NAME}/include)
	INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/${TARGET_NAME})
	INCLUDE_DIRECTORIES( ${PROJECT_BINARY_DIR}/${TARGET_NAME})#为了ui生成的头文件

    INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/PluginOsg)
    INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/PluginXml)

    INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/LibPcl)
    INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/LibCommon)
    INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/LibUiQt)
    INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/LibUiWrapOsg)
    INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/LibUiWrapMachining)
    INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/LibUiWrapVtk)

    # INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/LibReflectionOsg)
	LINK_DIRECTORIES( ${PROJECT_BINARY_DIR}/lib)
    LINK_DIRECTORIES( ${PROJECT_BINARY_DIR}/LibCommon)
    LINK_DIRECTORIES( ${PROJECT_BINARY_DIR}/LibUiQt)
	
    INCLUDE_DIRECTORIES(${OSG_INCLUDE_DIR})
    LINK_DIRECTORIES(${OSG_LIB_DIR})

    INCLUDE_DIRECTORIES(${VTK_INCLUDE_DIR})
    LINK_DIRECTORIES(${VTK_LIB_DIR})

    INCLUDE_DIRECTORIES(${QUAZIP_INCLUDE_DIR})
	LINK_DIRECTORIES(${QUAZIP_LIB_DIR})

    LINK_DIRECTORIES(${TINYXML2_LIB_DIR})

	INCLUDE_DIRECTORIES( ${QT_INCLUDE_DIR})
	INCLUDE_DIRECTORIES( ${QT_INCLUDE_DIR}/QtCore)
	INCLUDE_DIRECTORIES( ${QT_INCLUDE_DIR}/QtWidgets)
    INCLUDE_DIRECTORIES( ${QT_INCLUDE_DIR}/QtGui)
    INCLUDE_DIRECTORIES( ${QT_INCLUDE_DIR}/QtOpenGL)
    INCLUDE_DIRECTORIES( ${QT_INCLUDE_DIR}/QtANGLE)
    LINK_DIRECTORIES(${QT_LIB_DIR})

    INCLUDE_DIRECTORIES( ${QT_TABTOOLBAR_INCLUDE_DIR})
    LINK_DIRECTORIES( ${QT_TABTOOLBAR_LIB_DIR} )

    include_directories(${PCL_INCLUDE_DIR})
    link_directories(${PCL_LIB_DIR})

    include_directories(${SPDLOG_INCLUDE_DIR})
    link_directories(${SPDLOG_LIB_DIR})
find_package(Qt5Widgets)

ADD_DEFINITIONS (${Qt5Widgets_DEFINITIONS})

FILE(GLOB_RECURSE ThisTarget_INCLUDE_LIST "${PROJECT_SOURCE_DIR}/${TARGET_NAME}/*.h")
FILE(GLOB_RECURSE ThisTarget_SRC_LIST "${PROJECT_SOURCE_DIR}/${TARGET_NAME}/*.cpp")

FILE(GLOB QTDEMO_UI_LIST "${PROJECT_SOURCE_DIR}/${TARGET_NAME}/*.ui")
FILE(GLOB QTDEMO_RESOURCE_LIST "${PROJECT_SOURCE_DIR}/${TARGET_NAME}/*.qrc")

source_group("include" FILES ${ThisTarget_INCLUDE_LIST})
source_group("src" FILES ${ThisTarget_SRC_LIST})
source_group("ui" FILES ${QTDEMO_UI_LIST})
source_group("resource" FILES ${QTDEMO_RESOURCE_LIST})

qt5_wrap_cpp(example_MOCS 	${ThisTarget_INCLUDE_LIST})
QT5_WRAP_UI(example_UIS ${QTDEMO_UI_LIST} )#OPTIONS("uic -help")
qt5_add_resources(example_RCC_SRCS ${QTDEMO_RESOURCE_LIST} )#OPTIONS("rcc -help")
source_group("generated_file" FILES ${example_MOCS} ${example_UIS} ${example_RCC_SRCS} )

ADD_EXECUTABLE(${TARGET_NAME} ${ThisTarget_SRC_LIST} ${ThisTarget_INCLUDE_LIST} ${example_MOCS}  ${example_UIS}  ${example_RCC_SRCS} ${QTDEMO_UI_LIST} ${QTDEMO_RESOURCE_LIST}  )#${example_MOCS_Share}

IF (UNIX)
    SET(ADDITIONAL_LIBRARIES_RELEASE
        Qt5Widgets
        Qt5Core
        Qt5Gui
        Qt5PrintSupport
        TabToolbar
        LibCommon
        LibUiQt
        )
    SET(ADDITIONAL_LIBRARIES_DEBUG
        Qt5Widgets
        Qt5Core
        Qt5Gui
        Qt5PrintSupport
        TabToolbar
        LibCommond
        LibUiQtd
        )
ELSEIF(WIN32)
    SET(ADDITIONAL_LIBRARIES_RELEASE
        Qt5Widgets
        Qt5Core
        Qt5Gui
        Qt5PrintSupport
        TabToolbar
        LibCommon
        LibUiQt
        # PluginOsg
        #PluginXml
        )
    SET(ADDITIONAL_LIBRARIES_DEBUG
        Qt5Widgetsd
        Qt5Cored
        Qt5Guid
        Qt5PrintSupportd
        TabToolbard
        LibCommond
        LibUiQtd
        # PluginOsgd
        #PluginXmld
        )
ELSE()
ENDIF()



TARGET_LINK_LIBRARIES(${TARGET_NAME} PRIVATE debug "${ADDITIONAL_LIBRARIES_DEBUG}" PRIVATE optimized "${ADDITIONAL_LIBRARIES_RELEASE}")
set_target_properties(${TARGET_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_BINARY_DIR}/bin)
set_target_properties(${TARGET_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_BINARY_DIR}/bin)
set_target_properties(${TARGET_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${PROJECT_BINARY_DIR}/bin)

#set_target_properties(${TARGET_NAME} PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:CONSOLE /ENTRY:mainCRTStartup")# WINDOWS

#设置vs的调试环境
#put the code "%PATH%" at the end of all paths to avoid conflict with other software's path var.
set(DEBUG_ENVI "PATH=" 
                ${OSG_BIN_DIR}
                ${OSG_3RD_PARTY_BIN_DIR} 
                ${VTK_BIN_DIR}
                ${QT_BIN_DIR} 
                ${RTTR_BIN_DIR} 
                ${QT_TABTOOLBAR_BIN_DIR}
                ${COIN3D_BIN_DIR} 
                ${QUAZIP_BIN_DIR} 
                ${PCL_BIN_DIR} 
                ${OCC_BIN_DIR} 
                ${PROJECT_BINARY_DIR}/bin/plugin
                "%PATH%"
                )

set_target_properties(${TARGET_NAME} PROPERTIES VS_DEBUGGER_ENVIRONMENT "${DEBUG_ENVI}")
set_target_properties(${TARGET_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}")



